import request from '@/utils/request';

const PRE_URL = '/sys/res';

/**
 * 获取所有父节点资源
 */
export async function queryAllParents() {
  return request(`${PRE_URL}/getAllParents`, {
    method: 'POST',
    data: {},
  });
}

/**
 * 获取资源树
 */
export async function queryResTree() {
  return request(`${PRE_URL}/resTree`, {
    method: 'POST',
  });
}
/**
 * 获取部门资源树
 */
export async function queryDepartmentResTree() {
  return request(`${PRE_URL}/departmentResTree`, {
    method: 'POST',
  });
}
/**
 * 获取用户拥有的资源列表
 */
export async function queryUserRes() {
  return request(`${PRE_URL}/userRes`, {
    method: 'POST',
  });
}

/**
 * 获取当前权限设置列表
 */
export async function allMask() {
  return request(`${PRE_URL}/allMask`, {
    method: 'POST',
  });
}

/**
 * 根据条件查询资源列表
 * @param {*} params
 */
export async function queryRes(params) {
  return request(`${PRE_URL}/getByPage`, {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

/**
 * 添加资源
 * @param {*} params
 */
export async function addRes(params) {
  return request(`${PRE_URL}/add`, {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

/**
 * 删除资源
 * @param {Long} id 资源Id
 */
export async function delRes(id) {
  return request(`${PRE_URL}/del`, {
    method: 'POST',
    data: {
      resId: id,
    },
  });
}

/**
 * 修改资源
 * @param {*} params
 */
export async function editRes(params) {
  return request(`${PRE_URL}/edit`, {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

/**
 * 申请资源
 * @param {*} params
 */
export async function applyUserRes(params) {
  return request(`${PRE_URL}/applyUserRes`, {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

/**
 * 获取申请列表
 * @param {*} params
 */
export async function getApplies() {
  return request(`${PRE_URL}/getApplies`, {
    method: 'POST',
  });
}

/**
 * 审批资源
 * @param {*} params
 */
export async function approve(params) {
  return request(`${PRE_URL}/approve`, {
    method: 'POST',
    data: {
      ...params,
    },
  });
}
